
class Compose:
    def __init__(self, *transform_list):
        self.transform_list = transform_list

    def __call__(self, image, annotations, params={}):
        for argument in self.transform_list:
            image, annotations = argument(image, annotations, params=params)

        return image, annotations

class MapDatasetArgument:
    def __init__(self, dataset_map, default=None):
        self.dataset_map = dataset_map
        self.default = default

    def __call__(self, image, annotations, params={}):
        if params["base_dataset_name"] in self.dataset_map:
            if self.dataset_map[params["base_dataset_name"]] is None:
                return image, annotations
            else:
                return self.dataset_map[params["base_dataset_name"]](image, annotations, params=params)
        else:
            if self.default is None:
                return image, annotations
            else:
                return self.default(image, annotations, params=params)
